#include "Zone.h"
#include <Game/World/Systems/ZoneSystem.h>
#include <Game/World/Systems/RoomSystem.h>

#include <Game/GameManager.h>
#include <Game/EntityManager.h>

using namespace Game;
using namespace World;
using namespace Components;
using namespace Totem;

Zone::Zone(Entity &owner, const T_String &type, Systems::ZoneSystem &zoneSystem)
	: Component(type), owner(owner), zoneSystem(zoneSystem), roomSystem(NULL), 
	  enterEventId("ENTER"), leaveEventId("LEAVE")
{
	owner.registerToEvent2<Entity&, const U32&>(enterEventId).connect(this, &Zone::onEnter);
	owner.registerToEvent2<Entity&, const U32&>(leaveEventId).connect(this, &Zone::onLeave);

	zoneSystem.add(this);
	roomSystem = new Systems::RoomSystem(zoneSystem.getGameMgr());

	//Add some rooms to zone
	Entity &room_test1 = roomSystem->createRoom();
	Entity &room_test2 = roomSystem->createRoom();
}

Zone::~Zone()
{
	if(roomSystem)
		delete roomSystem;
}

void Zone::update(const F32 &dt)
{
	//Anything that should update each tick for generic rooms?
	//-probably not... this should be added via new components and handled there (weather systems, etc)
}

void Zone::onEnter(Entity &entity, const U32 &direction)
{

}

void Zone::onLeave(Entity &entity, const U32 &direction)
{
}
